package Porperties;

public class Customer implements  Comparable<Customer>{
    String name;
    int age;
    public Customer(String name,int age){
        this.name =name;
        this.age =age;
    }
    //重写toString方法
    public String toString() {
        return "Customer{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
    //重写Customer方法，自定义排序规则
    public int compareTo(Customer o) {
        if (this.age == o.age) {
            return this.name.compareTo(o.name);
        }else { return this.age -o.age;}//结果可能=0  >0   <0.
    }
}
